import { mapGetters } from "vuex";
import Alert from "vux/src/components/alert/index.vue";

import template from "./walletTemplate";
const { render, staticRenderFns } = template;

export default {
  render,
  staticRenderFns,
  components: {
    Alert,
  },
  data() {
    return {
      isTourist: false,
      isTouristFlag: false,
      isTouristTip: "",
      isBindBank: false,
      iconEyesFlag: true,

      refreshClass: false, //刷新
    };
  },
  created() {
    this.$store.dispatch("SET_CASINO_SWITCH", { Obj: {} });
    this.eyes = localStorage.getItem("eyes");
    if (this.eyes && this.eyes == "true") {
      this.iconEyesFlag = true;
    }
    if (this.eyes && this.eyes == "false") {
      this.iconEyesFlag = false;
    }

    if (this.accountData.is_tourist && this.accountData.is_tourist === 1) {
      this.isTourist = true;
      if (this.isTourist && this.accountData.tips.msg !== "") {
        this.isTouristTip = this.accountData.tips.msg;
        this.isTouristFlag = true;
      }
    }

    this.$nextTick(() => {
      if (
        this.accountData.is_tourist === 2 &&
        this.accountData.is_banded_bank === 0
      ) {
        this.isBindBank = true;
      }
    });
  },
  computed: {
    ...mapGetters(["accountData", "casinoSwitch"]),
  },
  methods: {
    clickRefresh() {
      if (!this.refreshClass) {
        this.refreshClass = true;
        this.$store.dispatch("SET_ACCOUNT_DATA", { Obj: {} });
        setTimeout(() => {
          this.refreshClass = false;
        }, 2000);
      }
    },
    clickWithdraw() {
      if (this.accountData) {
        if (
          this.accountData.is_tourist === 2 &&
          this.accountData.is_banded_bank === 0
        ) {
          this.isBindBank = true;
          return;
        }
        if (this.accountData.cash_id && this.accountData.cash_id != 0) {
          this.$router.push({
            path: "/whdProgress",
            query: { cash_id: this.accountData.cash_id },
          });
        } else {
          this.$router.push({
            path: "/withdraw",
          });
        }
      }
    },
    iconEyes() {
      //明文密文
      this.iconEyesFlag = !this.iconEyesFlag;
      localStorage.setItem("eyes", this.iconEyesFlag);
    },
    goToBind() {
      this.$router.push({ path: "/bank/bankList" });
    },
  },
  watch: {
    accountData(obj) {
      if (obj.is_tourist && obj.is_tourist === 1) {
        this.isTourist = true;
        if (this.isTourist && obj.tips.msg !== "") {
          this.isTouristTip = obj.tips.msg;
          this.isTouristFlag = true;
        }
      }
    },
  },
};

// WEBPACK FOOTER //
// ./src/components/wallet/wallet.vue
